package org.gg.boom.modules.schedule.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.gg.boom.common.utils.ConvertUtils;
import org.gg.boom.modules.schedule.mapper.ScheduleJobLogDao;
import org.gg.boom.modules.schedule.model.dto.ScheduleJobLogDTO;
import org.gg.boom.modules.schedule.model.entity.ScheduleJobLogEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ScheduleJobLogService extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> {

    public Page<ScheduleJobLogDTO> page(Map<String, Object> params) {
//		IPage<ScheduleJobLogEntity> page = baseMapper.selectPage(
//			getPage(params, Constant.CREATE_DATE, false),
//			getWrapper(params)
//		);
//		return getPageData(page, ScheduleJobLogDTO.class);
        return null;
    }

    private QueryWrapper<ScheduleJobLogEntity> getWrapper(Map<String, Object> params) {
        String jobId = (String) params.get("jobId");

        QueryWrapper<ScheduleJobLogEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(jobId), "job_id", jobId);

        return wrapper;
    }

    public ScheduleJobLogDTO get(Long id) {
        ScheduleJobLogEntity entity = baseMapper.selectById(id);
        return ConvertUtils.sourceToTarget(entity, ScheduleJobLogDTO.class);
    }

}
